<template>
	<view class="swiper">
		<u-swiper :list="swiperData" :current="swiperCurrent" height="300" keyName="image" indicator
			indicatorMode="line" circular @click="goBanner($event)"></u-swiper>
	</view>
</template>

<script>
import { noticePage } from '@/api/data.js'
import baseApi from "@/config/baseApi.js";
export default {
	data() {
		return {
			baseApi: baseApi,
			swiperData: [],
			swiperCurrent: 0,
			param: {
				pageNumber: 1,
				pageSize: 10,
				title: ''
			},
			data:[],
		}
	},
	mounted() {
		this.noticePage()
	},
	methods: {
		noticePage() {
			noticePage(this.param).then(res => {
				if (res.code == '200') {
					if (res.data.records && res.data.records.length) {
						res.data.records = res.data.records.map(e => {
							return {
								...e,
								coverImage: 'http://127.0.0.1:4444/api/upload/' + e.coverImage,
							}
						})
						this.data=res.data.records;
						this.swiperData = res.data.records.map(e=>e.coverImage)
					}
				}
			})
		},
		goBanner(e) {
			uni.navigateTo({ url: `/pages/home/info?id=${this.data[e].id}` });
		},
	}
}
</script>

<style scoped>
.swiper {
	width: 100%;
	margin: 0 0 24rpx 0;
	box-sizing: border-box;
}
</style>
